package com.linsir.lin.controller.meta;

import com.linsir.core.BaseResponse;
import com.linsir.lin.dto.GridDTO;
import com.linsir.lin.dto.MetaObjectDTO;
import com.linsir.lin.pojo.MetaObject;
import com.linsir.lin.service.MetaObjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.lang.reflect.InvocationTargetException;


@RestController
@RequestMapping("/metaObject")
public class MetaObjectController {

    @Autowired
    private MetaObjectService metaObjectService;

    @RequestMapping(value = "/add", method = {RequestMethod.POST, RequestMethod.GET})
    public BaseResponse<MetaObject> doAddMetaObject(MetaObject metaObject) {
        return metaObjectService.add(metaObject);
    }

    @RequestMapping(value = "/grid", method = {RequestMethod.POST, RequestMethod.GET})
    public GridDTO<MetaObjectDTO> grid(String page,
                                       String limit,
                                       String searchParams) throws IOException, InvocationTargetException, IllegalAccessException {
        return metaObjectService.grid(page,limit,searchParams);
    }

    @RequestMapping(value = "/batchDel",method = {RequestMethod.GET})
    public BaseResponse<Boolean> batchDel(String ids)
    {
       return metaObjectService.batchDel(ids);
    }

}
